<template>
	<gui-page ref="guiPage" :customHeader="true">
		<template v-slot:gHeader>
			<nav-bar-custom left-icon="left" :title="$t('translationImage.incomingInspection')"></nav-bar-custom>
		</template>
		<template v-slot:gBody>
			<view>
				<view class="aili-placeholder"></view>
				<view class="card-boxCustom" v-for="(x, i) in data.item.materialGroups" :key="i" @click="goPage(x)">
					<view class="card-body">
						<view class="card-body-item">
							<text class="body-item-title">{{ $t('purchaseReturn.generateDate') }}：</text>
							{{ data.item.instockTime }}
						</view>
						<view class="card-body-item">
							<text class="body-item-title">{{ $t('distributedEnter.materialCode') }}：</text>
							{{ x.materialCode }}
						</view>
						<view class="card-body-item">
							<text class="body-item-title">{{ $t('distributedEnter.materialName') }}：</text>
							{{ x.materialName }}
						</view>
						<view class="card-body-item">
							<text class="body-item-title">
								{{ $t('translationImage.supplierName') }}：</text>{{ data.item.supplierName }}
						</view>
						<view class="card-body-item">
							<text class="body-item-title">
								{{ $t('distributedEnter.materialSpec') }}：</text>{{ x.materialSpec }}
						</view>
						<view class="card-body-item">
							<text class="body-item-title"> {{ $t('distributedEnter.qty') }}：</text>{{ x.qty }}
						</view>
						<view class="card-body-item">
							<text class="body-item-title"> {{ $t('distributedEnter.uom') }}：</text>{{ x.unit }}
						</view>
						<uni-tag v-if="x.checkStatus == 'waitCheck'" class="icq-status-tag" style="font-size: 16px;"
							:inverted="true" :text="$t('translationImage.checkedNo')" type="primary" />
						<uni-tag v-else-if="x.checkStatus == 'pass'" class="icq-status-tag" style="font-size: 16px;"
							:inverted="true" :text="$t('translationImage.qualified')" type="success" />
						<uni-tag v-else-if="x.checkStatus == 'fail'" class="icq-status-tag" style="font-size: 16px;"
							:inverted="true" :text="$t('translationImage.qualifiedNo')" type="error" />
					</view>
				</view>
			</view>
		</template>
	</gui-page>
</template>

<script setup>
import { navigate } from '@/utils/routerSkip.js';
import { basPdaOperationLogFn } from '@/utils/index.js';
import { OPERATION_SEARCH, OPERATION_REASCT, OPERATION_LOOK, OPERATION_CHOOSE } from '@/constant/index.js'
import { reactive, computed, onMounted } from 'vue';
import { useStore } from "vuex";
import { getIncomingMaterial } from "@/api/api.js"
import { onShow } from '@dcloudio/uni-app';
import graceJS from "@/Grace6/js/grace.js";
const props = defineProps({
	foo: String
})
let store = useStore();
let data = reactive({
	item: {}
})
onShow(() => {
	getIncomingMaterialFn()
})
// 获取页面数据
const getIncomingMaterialFn = () => {
	let parmes = {
		isSp: 0,// 代表是否是五金仓
		instockTimeStart: '',
		instockTimeEnd: '',
		checkStatus: '',
		instockCode: props.instockCode,
		current:1,
		size:50
	}
	getIncomingMaterial(parmes).then(res => {
		try {
			let inputParameter = JSON.stringify(parmes)
			let returnParameter = JSON.stringify(res)
			let operationPicture = '来料检验'
			let callInterface = res.rquestUrl
			let opertionParmes = {
				inputParameter,
				returnParameter,
				operationPicture,
				callInterface,
				responseCode: res.code,//返回状态
				errorMessage: res.msg,//错误信息
				isPass: res.code == 0 ? 'Y' : 'N',//是否成功 Y N
				operationType: OPERATION_LOOK,
				module: 'WMS',
				source: "PDA",
			}
			basPdaOperationLogFn(opertionParmes)
		} catch (error) {
		}
		if (res.code == 0) {
			data.item = res.data.records[0];
			console.log(data.item, 'getIncomingMaterial')
		} else {
			graceJS.msg(res.msg);
		}
	})
}
const goPage = (x) => {
	if (x.checkStatus == 'pass') {
		return
	}
	try {
		let inputParameter = x.materialCode
		let returnParameter = '无'
		let operationPicture = '来料检验'
		let callInterface = '无'
		let opertionParmes = {
			inputParameter,
			returnParameter,
			operationPicture,
			callInterface,
			responseCode: '无',//返回状态
			errorMessage: '无',//错误信息
			isPass: 'Y',//是否成功 Y N
			operationType: OPERATION_CHOOSE,
			module: 'WMS',
			source: "PDA",
		}
		basPdaOperationLogFn(opertionParmes)
	} catch (error) {

	}
	x.supplierName = data.item.supplierName
	x.k3Id = data.item.k3Id
	x.instockTime = data.item.instockTime
	x.instockCode = data.item.instockCode
	store.commit('editIqcInfo', x)
	navigate({
		url: `/pages/qms/iqcInput?materialCode=${x.materialCode}`
	})
}
</script>

<style lang="scss" scoped>
.icq-status-tag {
	position: absolute;
	right: 0;
	bottom: 0;
}
</style>
